<?
include("inc_security.php");

//Khai báo biến khi thêm mới
$gs_title				= "Cuối trang";
$gs_action				= getURL();
$gs_redirect			= getURL();
$gs_errorMsg			= "";

//Get data edit
$record_id				= $con_static_footer;
$db_edit					= new db_query("SELECT * FROM statics_multi WHERE sta_id = " . $record_id . " AND lang_id = " . $lang_id);
if(mysql_num_rows($db_edit->result) == 0){
	//Redirect if can not find data
	redirect($gs_error);
}
$edit						= mysql_fetch_array($db_edit->result);
unset($db_edit);

//Lấy dữ liệu đề giữ nguyên trạng thái khi submit error
$sta_description	= getValue("sta_description", "str", "POST", $edit["sta_description"]);

//Get action variable for add new data
$action					= getValue("action", "str", "POST", "");
//Check $action for insert new data
if($action == "execute"){
	
	/*
	Call class form:
	1). Ten truong
	2). Ten form
	3). Kieu du lieu , 0 : string , 1 : kieu int, 2 : kieu email, 3 : kieu double, 4 : kieu hash password
	4). Noi luu giu data  0 : post, 1 : variable
	5). Gia tri mac dinh, neu require thi phai lon hon hoac bang default
	6). Du lieu nay co can thiet hay khong
	7). Loi dua ra man hinh
	8). Chi co duy nhat trong database
	9). Loi dua ra man hinh neu co duplicate
	*/
	$myform = new generate_form();
	//Add table insert data
	$myform->addTable("statics_multi");
	$myform->add("sta_description", "sta_description", 0, 1, "", 0, "", 0, "");

	//Check form data
	$gs_errorMsg .= $myform->checkdata();
	
	if($gs_errorMsg == ""){
		
		//Insert to database
		$myform->removeHTML(0);
		$db_update = new db_execute($myform->generate_update_SQL("sta_id", $record_id));
		unset($db_update);
		
		//Redirect after insert complate
		redirect($gs_redirect);
		
	}//End if($gs_errorMsg == "")
	unset($myform);
	
}//End if($action == "insert")
?>
<html>
<head>
<title><?=$gs_title?></title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<style type="text/css" media="all">@import "../css/GSportal.css";</style>
<script language="javascript" src="../js/library.js"></script>
</head>
<body>
<div class="bg_title_content">
<div class="content_title" style="float:left"><?=$gs_title?></div>
</div>
<div align="center" class="content">
<?
$form = new form();
$form->create_form("edit", $gs_action, "post", "multipart/form-data");
$form->create_table();
?>
<tr>
	<td colspan="2">
		<script type="text/javascript" src="/js/tiny_mce/tiny_mce.js"></script>
        <script type="text/javascript">
				tinyMCE.init({
						// General options
						mode : "exact",
						elements : "sta_description",
						width : "700",
						height : "400",
						theme : "advanced",
						/* Dùng domain */
						remove_script_host : false,
						convert_urls : true,
						/* Dùng đường dẫn tuyệt đối */
						relative_urls : false,
						verify_html : true,
						cleanup : true,
						language : "vi",
						plugins : "emotions, table, paste, cleanupstyles",
						valid_elements : "a,b,blockquote,br,center,del,div,em,font,h2,h3,h4,i,img,ins,li,hr,ol,p,pre,s,span,strong,strike,sub,sup,table,tbody,td,th,tr,u,ul",
extended_valid_elements : "a[href|name|rel|style|target|title],b[style],blockquote[style|title],br[clear|title],center[],del[style|title],div[align|style|title|class],em[style|title],font[color|face|size|style|title],h2[],h3[],h4[],i[style|title],img[align|alt|border|height|hspace|idata|src|style|title|vspace|width],ins[style|title],li[style|title|type],hr[align|noshade|size|style|title],ol[style|title|type],p[align|style|title],pre[style|title],s[style|title],span[style|title|class],strong[style],strike[style|title],sub[style|title],sup[style|title],table[align|bgcolor|border|bordercolor|cellpadding|cellspacing|height|style|title|width],tbody[],td[align|bgcolor|colspan|height|nowrap|rowspan|style|title|valign|width],th[align|bgcolor|colspan|height|nowrap|rowspan|style|title|valign|width],tr[align|bgcolor|height|nowrap|style|title|valign],u[style|title],ul[style|title|type],",
invalid_styles : "behavior,background-image,background,list-style-image,expression,/*,*/",
				
						/* Theme options */
						theme_advanced_buttons1 : "bold,italic,underline,strikethrough,|,justifyleft,justifycenter,justifyright,justifyfull,fontselect,fontsizeselect,forecolor,backcolor",
						theme_advanced_buttons2 : "image,pasteword,link,unlink,emotions,|,table,tablecontrols,code",
						theme_advanced_buttons3 : "",
						theme_advanced_buttons4 : "",
						theme_advanced_toolbar_location : "top",
						theme_advanced_toolbar_align : "left",
						theme_advanced_statusbar_location : "bottom",
						theme_advanced_resizing : true,
						theme_advanced_resizing_use_cookie : false,
						theme_advanced_path : false, 
						/* Example content CSS (should be your site CSS) */
						content_css : "/css/tinyMCE.css"
				});
				
			</script>
        <textarea id="sta_description" name="sta_description" rows="20" cols="80" style="width: 700px"><?=$sta_description?></textarea>		
	</td>
</tr>
<?=$form->button("submit" . $form->ec . "reset", "submit" . $form->ec . "reset", "submit" . $form->ec . "reset", "Cập nhật" . $form->ec . "Làm lại", "Cập nhật" . $form->ec . "Làm lại", 'style="background:url(' . $gs_imagepath . 'button_1.gif) no-repeat"' . $form->ec . 'style="background:url(' . $gs_imagepath . 'button_2.gif)"', "");?>
<?=$form->hidden("action", "action", "execute", "");?>
<?
$form->close_table();
$form->close_form();
unset($form);
?>
</div>
</body>
</html>
<script language="javascript">ButtonLeftFrame();</script>